﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Model;
using Common;
using MySql.Data.MySqlClient;
namespace DAL
{
    public class StaffDAL
    {
        #region 获取对象实体
        public int GetStaffNameByStaffID(String StaffID, String BossID, String strWhere, out int isSuccess, out String StaffName)
        {
            isSuccess = 0; StaffName = "";
            using (MySqlConnection conn = SqlHelper.Settings.GetBrandMySqlConnection(false))
            {
                try
                {
                    MySqlCommand cmd = new MySqlCommand("P_CheckStaffIDByStaffID_MZ", conn);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@StaffID_Para", MySqlDbType.VarChar, 20).Value = StaffID;
                    cmd.Parameters.Add("@BossID_Para", MySqlDbType.VarChar, 20).Value = BossID;
                    cmd.Parameters.Add("@strWhere", MySqlDbType.VarChar, 100).Value = strWhere;
                    cmd.Parameters.Add("@StaffName_Para", MySqlDbType.VarChar, 50).Value = "";
                    cmd.Parameters.Add("@IsSuccess_Para", MySqlDbType.Int32).Value = 0;

                    cmd.Parameters["@StaffName_Para"].Direction = ParameterDirection.Output;
                    cmd.Parameters["@IsSuccess_Para"].Direction = ParameterDirection.Output;
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    cmd.ExecuteNonQuery();
                    Object IsSuccessObj = cmd.Parameters["@IsSuccess_Para"].Value;
                    isSuccess = IsSuccessObj == null || IsSuccessObj.ToString() == string.Empty ? -5 : (int)IsSuccessObj;
                    Object StaffNameObj = cmd.Parameters["@StaffName_Para"].Value;
                    StaffName = StaffNameObj == null || StaffNameObj.ToString() == string.Empty ? "" : (String)StaffNameObj;


                    return isSuccess;
                }
                catch (Exception ex)
                {
#if DEBUG
                    throw ex;
#else
                    return -1000;
#endif
                }
                finally
                {
                    conn.Close();
                }
            }
        }
        #endregion

    }
}
